class Solution:
    def lengthOfLongestSubstring(self, s: str) -> int:
        i, j, result = 0, 1, 0
        while j < len(s):
            if s[i:j].find(s[j]) > -1:
                if result < j - i:
                    result = j - i
                i = i + 1
            else:
                j += 1
        else:
            if result < len(s) - i:
                result = len(s) - i
        return result


if __name__ == "__main__":
    text = "sdshsgdj"
    print("text:{0}, longest substring length:{1}".format(
        text, Solution().lengthOfLongestSubstring(text)))
